package thread;

import java.util.concurrent.Semaphore;

public class Demo42 {
    public static void main(String[] args) throws InterruptedException {
        // 信号量 如果到0还继续获取 那么就会阻塞
        Semaphore semaphore = new Semaphore(2);
        semaphore.release();
        System.out.println("释放");
        semaphore.acquire();
        System.out.println("获取");
        semaphore.acquire();
        System.out.println("获取");
        semaphore.acquire();
        System.out.println("获取");
        // 阻塞
        semaphore.acquire();
        System.out.println("获取");
    }
}
